<?php namespace web\home\controller;
/** .-------------------------------------------------------------------
 * |  Software: [HDPHP framework]
 * |      Site: www.hdphp.com
 * |-------------------------------------------------------------------
 * |    Author: 向军 <2300071698@qq.com>
 * |    WeChat: aihoudun
 * | Copyright (c) 2012-2019, www.houdunwang.com. All Rights Reserved.
 * '-------------------------------------------------------------------*/

class Entry extends Common{
	//首页
	public function index(){
//		获取文章数据
		$carData=Db::table('article')->join('category','category_cid','=','cid')->where('is_recycle',0)->orderBy('sendtime','DESC')->count();
//		执行分页
		$page=Page::row(1)->make($carData);
		$artData=Db::table('article')->join('category','category_cid','=','cid')->where('is_recycle',0)->orderBy('sendtime','DESC')->limit(Page::limit())->get();

//		处理标签数据
		foreach($artData as $k=>$v){
			$artData[$k]['tag']=Db::table('article_tag')
			->join('tag','tag_tid','=','tid')->field(array('tid','tname'))
			->where('article_aid',$v['aid'])->get();
		}
		
		View::with('page',$page);
		View::with('artData',$artData);

		View::make();
	}
}